//https://leetcode-cn.com/problems/robot-return-to-origin/

#include <stdio.h>
#include <string.h>

// bool judgeCircle(char* moves) {
//     int n = strlen(moves), x = 0, y = 0;
//     for (int i = 0; i < n; i++) {
//         if (moves[i] == 'U') {
//             y--;
//         } else if (moves[i] == 'D') {
//             y++;
//         } else if (moves[i] == 'L') {
//             x--;
//         } else if (moves[i] == 'R') {
//             x++;
//         }
//     }
//     return x == 0 && y == 0;
// }

bool judgeCircle(char *moves)
{
    int len = strlen(moves);
    int x = 0, y = 0;
    for (int id = 0; id < len; id++)
    {
        char c = moves[id];
        if (c == 'U')
        {
            y++;
        }
        else if (c == 'D')
        {
            y--;
        }
        else if (c == 'L')
        {
            x--;
        }
        else if (c == 'R')
        {
            x++;
        }
    }

    return x == 0 && y == 0;
}